package com.example.huoher.miniaddressbook;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        editTextusername = findViewById(R.id.editText_username);
        editTextpassword= findViewById(R.id.editText_password);
    }

//    private Button button = findViewById(R.id.button_login);
    private EditText editTextusername;
    private EditText editTextpassword;


    public void addresslogin(View view) {
       boolean re = dotruefalse();
       if (re == true){
           Intent intent = new Intent(MainActivity.this,ContactsActivity.class);
           startActivity(intent);
       }else {
           Toast.makeText(this, "对不起，用户名是admin密码是123请重新输入", Toast.LENGTH_SHORT).show();
       }
    }

    public boolean dotruefalse(){
        String username = editTextusername.getText().toString();
        String password = editTextpassword.getText().toString();
        if (username.equals("admin")&&password.equals("123")){
            return true;
        } else {
            return false;
        }
    }

}
